package com.lagou.dao;

import com.lagou.domain.Student;
import com.lagou.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

/**
 * 增加学生dao层
 */
public class AddStudentDao {
	public static void addStudent(Student student) throws SQLException {
		//创建工具类
		QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());
		//添加学生的sql
		String sql = "INSERT INTO student VALUES (?,?,?,?);";
		//将传入的对象获取对应的属性值
		Object[] params = {student.getId(),student.getName(),student.getSex(),student.getBirth()};
		//执行插入操作
		int update = qr.update(sql, params);
	}
}
